<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace Utilities\Session;

use Zend\Session\Container;
use Zend\Session\SessionManager;
use User\Entity\Customer;

class SessionFacade
{

    /**
     */
    public function getSessionId()
    {
        $manager = new SessionManager();
        
        return $manager->getId();
    }

    /**
     */
    public function setStore($store)
    {
        $session = new Container('store');
        
        $session->store = $store;
    }

    /**
     */
    public function getStore()
    {
        $session = new Container('store');
        
        return $session->store;
    }

    /**
     */
    public function setCustomer($customer)
    {
        $session = new Container('authentication');
        
        $session->customer = $customer;
    }

    /**
     */
    public function getCustomer()
    {       
        $session = new Container('authentication');
        
        return $session->customer;
    }

    /**
     */
    public function getAuthenticationInfo()
    {
        $opauth = $_SESSION['opauth'];
        
        if (array_key_exists('auth', $opauth) && array_key_exists('info', $opauth['auth']))
            return $opauth['auth']['info'];
        
        return null;
    }

    /**
     */
    public function getAuthenticationError()
    {
        $opauth = $_SESSION['opauth'];
        
        if (array_key_exists('error', $opauth))
            return $opauth['error'];
        
        return null;
    }

    /**
     */
    public function setCurrentUrl($url)
    {
        $session = new Container('navigation');
        
        $session->currentUrl = $url;
    }

    /**
     */
    public function getCurrentUrl()
    {
        $session = new Container('navigation');
        
        return $session->currentUrl;
    }

    /**
     */
    public function setLocale($locale)
    {
        $session = new Container('store');
        
        $session->locale = $locale;
    }

    /**
     */
    public function getLocale()
    {
        $session = new Container('store');
        
        return $session->locale;
    }
}

?>